/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.Random;

/**
 * <p>Project: javase - Arr2
 * <p>Powered by webrx On 2021-11-26 10:21:42
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr2 {
    public static void main(String[] args) {
        var nums = new Integer[10];
        var rand = new Random();
        for (int i = 0; i < nums.length; i++) {
            nums[i] = rand.nextInt(100) + 1;
        }
        //利用Arrays工具类，转换为String字符串输出，[26, 71, 89, 53, 96, 11, 70, 69, 43, 79]
        System.out.println(Arrays.toString(nums));

        Arrays.sort(nums);

        System.out.println(Arrays.toString(nums));

        Arrays.sort(nums, (a, b) -> b - a);

        System.out.println(Arrays.toString(nums));

        //乱序
        Arrays.sort(nums, (a, b) -> rand.nextBoolean() ? 1 : -1);
        Arrays.sort(nums, (a, b) -> rand.nextBoolean() ? 1 : -1);
        Arrays.sort(nums, (a, b) -> rand.nextBoolean() ? 1 : -1);
        System.out.println(Arrays.toString(nums));


    }
}
